<?php
require_once '../libs/common.php';
setCosHeader();
$database=getDbConn();
//$cache=getCache();
$ad_position_sql = 'select * from ad_position where position_key="home_slider"';
$result = $database->queryOne($ad_position_sql);
$data=[];
if($result){
	$positionid=$result['id'];
	$sql = 'select * from ad where positionid = :id and is_display=1';
	$array = array(
	      ':id' =>$positionid
	);
	$ads = $database->queryAll($sql, $array);
	//echo json_encode(array('status'=>1,'msg'=>'查询成功','data'=>$ads));
	$data['home_slider']=$ads;
}
$shop_category_sql="select * from shop_category where parentid=0 order by sort asc";
$shopcategorys = $database->queryAll($shop_category_sql);
if($shopcategorys){
	if(count($shopcategorys)>8){
		$data['shopcategorys']=array_chunk($shopcategorys,8);
		//$cache->set('home_shopcategorys',array_chunk($shopcategorys,8),60);
	}else{
		$data['shopcategorys']=$shopcategorys;
		
	}
	
}

echo json_encode($data);

